import { reactive, ref } from 'vue'
import { TASK_QUESTION_TYPE } from '@/utils/dictionary'
import { getTaskInspectionType } from '@/api/task/index'

const startList = [
  { type: 'input', key: 'longitude', label: '经纬度', props: { placeholder: '起点经度' }},
  { type: 'input', key: 'latitude', label: '', props: { placeholder: '起点纬度' }}
]

const queList = ref([])

export const form = reactive({
  userForm: {
    questionCode: null,
    longitude: null,
    latitude: null,
    fileImage: ''
  },
  userRules: {
    // questionName: [{ required: true, type: 'number', message: '请选择问题类型', trigger: 'blur' }],
    // longitude: [{ required: true, type: 'number', message: '请输入', trigger: ['blur', 'change', 'input'] }],
    // latitude: [{ required: true, type: 'number', message: '请输入', trigger: ['blur', 'change', 'input'] }]
  },
  formItem: [
    { type: 'select', key: 'questionCode', label: '问题类型', props: { options: queList, placeholder: '请选择问题类型', clearable: true }},
    { type: 'inputGroup', key: 'startVal', label: '经纬度', values: startList },
    { type: 'oss', key: 'fileImage', label: '图片' }
  ]
})

export const getquestionTypeList = async() => {
  const { data } = await getTaskInspectionType()
  queList.value = data?.map(item => ({
    ...item,
    value: item.code,
    label: item.content
  }))
}
